//
//  Head.m
//  TapEnglish
//
//  Created by 이선동 on 11. 4. 13..
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "Head.h"


@implementation Head

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [labelCaption release];
    [labelPinyin release];
    [labelEnglish release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [labelCaption release];
    labelCaption = nil;
    [labelPinyin release];
    labelPinyin = nil;
    [labelEnglish release];
    labelEnglish = nil;
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (void)viewWillAppear:(BOOL)animated {
    [self soundPlay:@"KOR_head.aiff"];    
}

- (IBAction)goHome:(id)sender {
    [self dismissModalViewControllerAnimated:YES];
}

- (IBAction)speakerTapped:(id)sender {
    [self soundPlay:[NSString stringWithFormat:@"KOR_%@.aiff", labelEnglish.text]];
}

SystemSoundID soundID;

CFURLRef baseURL;

- (void) soundPlay:(NSString *)audioName{
	NSString *sndPath = [[NSBundle mainBundle] pathForResource:audioName ofType:nil];
	baseURL = (CFURLRef)[[NSURL alloc] initFileURLWithPath:sndPath];
	AudioServicesCreateSystemSoundID(baseURL, &soundID);
	AudioServicesPlaySystemSound(soundID);
}

- (IBAction)button_01_tapped_hair:(id)sender {
    [self soundPlay:@"KOR_hair.aiff"];
    labelCaption.text=@"머리카락";
    //labelPinyin.text=@"かみ-の-け";
    labelEnglish.text=@"hair";
}

- (IBAction)button_02_tapped_eyebrow:(id)sender {
    [self soundPlay:@"KOR_eyebrow.aiff"];
    labelCaption.text=@"눈썹";
    //labelPinyin.text=@"まゆ";
    labelEnglish.text=@"eyebrow";
}

- (IBAction)button_03_tapped_ear:(id)sender {
    [self soundPlay:@"KOR_ear.aiff"];
    labelCaption.text=@"귀";
    //labelPinyin.text=@"みみ";
    labelEnglish.text=@"ear";
}

- (IBAction)button_04_tapped_cheek:(id)sender {
    [self soundPlay:@"KOR_cheek.aiff"];
    labelCaption.text=@"뺨";
    //labelPinyin.text=@"ほお";
    labelEnglish.text=@"cheek";
}

- (IBAction)button_05_tapped_chin:(id)sender {
    [self soundPlay:@"KOR_chin.aiff"];
    labelCaption.text=@"턱";
    //labelPinyin.text=@"あご";
    labelEnglish.text=@"chin";
}

- (IBAction)button_11_tapped_head:(id)sender {
    [self soundPlay:@"KOR_head.aiff"];
    labelCaption.text=@"머리";
    //labelPinyin.text=@"あたま";
    labelEnglish.text=@"head";
}

- (IBAction)button_12_tapped_eye:(id)sender {
    [self soundPlay:@"KOR_eye.aiff"];
    labelCaption.text=@"눈";
    //labelPinyin.text=@"め";
    labelEnglish.text=@"eye";
}

- (IBAction)button_13_tapped_nose:(id)sender {
    [self soundPlay:@"KOR_nose.aiff"];
    labelCaption.text=@"코";
    //labelPinyin.text=@"はな";
    labelEnglish.text=@"nose";
}

- (IBAction)button_14_tapped_mouth:(id)sender {
    [self soundPlay:@"KOR_mouth.aiff"];
    labelCaption.text=@"입";
    //labelPinyin.text=@"くち";
    labelEnglish.text=@"mouth";
}

- (IBAction)button_15_tapped_neck:(id)sender {
    [self soundPlay:@"KOR_neck.aiff"];
    labelCaption.text=@"목";
    //labelPinyin.text=@"くび";
    labelEnglish.text=@"neck";
}


@end
